package com.me.decorator;

/**
 * 装饰者类对象,继承饮品类,设置花费价格为自身价格+饮品类价格
 */
public class Decorator extends Drink {
    /**
     * 饮品类对象
     */
    private final Drink drink;

    /**
     * 组合(有参构造)
     *
     * @param drink 饮品类对象
     */
    public Decorator(Drink drink) {
        this.drink = drink;
    }

    @Override
    public float cost() {
        // getPrice 自己价格
        return getPrice() + drink.cost();
    }

    @Override
    public String getDes() {
        // drink.getDes() 输出被装饰者的信息
        return des + " " + getPrice() + " && " + drink.getDes();
    }

}
